package com.pig4cloud.pigx.knowledge.support.util;

import org.springframework.ai.chat.prompt.PromptTemplate;
import org.springframework.core.io.ClassPathResource;

import java.util.Map;

/**
 * PromptTemplate 构造器
 *
 * @author lengleng
 * @date 2024/9/27
 */
public class PromptBuilder {

	/**
	 * 渲染
	 * @param promptName 提示名称
	 * @return {@link PromptTemplate }
	 */
	public static String render(String promptName, Map<String, Object> model) {
		ClassPathResource classPathResource = new ClassPathResource("prompts/" + promptName);
		PromptTemplate promptTemplate = new PromptTemplate(classPathResource);
		return promptTemplate.render(model);
	}

	/**
	 * 呈现
	 * @param promptName 提示名称
	 * @return {@link String }
	 */
	public static String render(String promptName) {
		return render(promptName, Map.of());
	}

}
